package servlet;

import Hbase.StudentStatus;
import pojo.ST;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.List;

@WebServlet("/StudentStatusServlet")
public class StudentStatusServlet extends HttpServlet {

    public void init(HttpServletRequest req, HttpServletResponse resp) throws UnsupportedEncodingException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        resp.setCharacterEncoding("utf-8");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException,ServletException {
        init(req,resp);
        String status=req.getParameter("status");
        StudentStatus studentStatus = new StudentStatus();
        List<ST> display = studentStatus.Status(status);
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter pw = resp.getWriter();
//        for (int i = 0; i < display.size(); i++) {
//            System.out.println( display.get(i).getStudentID());
//            System.out.println( display.get(i).getStudentDate());
//            pw.write(display.get(i).getStudentID()+"   ");
//            pw.write(display.get(i).getStudentName()+"   ");
//            pw.write(display.get(i).getStudentSemester()+"   ");
//            pw.write(display.get(i).getStudentNumber()+"   ");
//            pw.write(display.get(i).getStudentDate()+"   ");
//            pw.write(display.get(i).getStudentStatus()+"</br>");
//
//        }
        HttpSession session = req.getSession();

        req.setAttribute("obj_data",display);

        req.getRequestDispatcher("/Student Status.jsp").forward(req,resp);

    }


    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }

}
